{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "path = ['final_heat_in000692.jpg', 'final_in000692_gray.jpg', 'fuse_heat_in000692.jpg', 'fuse_in000692_gray.jpg']\n",
    "\n",
    "img_0 =  cv.imread(path[0])\n",
    "img_1 =  cv.imread(path[1])\n",
    "img_2 =  cv.imread(path[2])\n",
    "img_3 =  cv.imread(path[3])\n",
    "x, _ = img_0.shape[0:2]\n",
    "h_space = np.ones((x,10,3)) * 512\n",
    "\n",
    "\n",
    "image_0 = np.hstack([img_0,h_space,img_1])\n",
    "image_1 = np.hstack([img_2,h_space,img_3])\n",
    "_, y = image_0.shape[0:2]\n",
    "v_space = np.ones((10,y,3)) * 512\n",
    "\n",
    "image_final = np.vstack([image_0,v_space,image_1])\n",
    "cv.imwrite('heatmaps.jpg', image_final)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([2, 3, 3])\n",
      "torch.Size([2, 3])\n",
      "tensor([[[1.],\n",
      "         [4.],\n",
      "         [1.]],\n",
      "\n",
      "        [[2.],\n",
      "         [2.],\n",
      "         [4.]]])\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "A = torch.Tensor([[[2, 3, 1], [1, 4, 0], [1, 0, 0]], [[2, 2, 0], [2, 0, 0], [3, 1, 4]]])\n",
    "print(A.size())\n",
    "\n",
    "B = torch.Tensor([[3, 2, 1], [2, 1, 3]]).long()\n",
    "print(B.size())\n",
    "B = B.view(2, 3, -1)\n",
    "B = B - 1\n",
    "\n",
    "C = torch.gather(A, 2, B)\n",
    "print(C)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
